package com.ddwl.gate.controller;

import com.ddwl.common.annotation.Auth;
import com.ddwl.common.constant.BaseEnum;
import com.ddwl.common.controller.BaseController;
import com.ddwl.gate.service.IdCardVerifyService;
import com.ddwl.schema.bo.gate.IDOCRAuthBo;
import com.ddwl.schema.bo.gate.TencentOCRAuthBo;
import com.ddwl.common.constant.OcrEnum;
import com.ddwl.schema.vo.base.RestVo;
import com.ddwl.schema.vo.gate.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 身份证校验
 * @author wenbin
 */
@Api(tags = "身份证校验")
@RequestMapping("verify")
@RestController
public class IdCardVerifyController extends BaseController {

    @Resource
    private IdCardVerifyService idCardVerifyService;

    @PostMapping("/faceVerify")
    @ApiOperation("人脸身份证校验")
    //@Auth(product = {BaseEnum.ProductEnum.WBM, BaseEnum.ProductEnum.WBM_OFFICE})
    public RestVo<FaceVerifyORCResultVo> faceVerify(@RequestBody TencentOCRAuthBo bo) throws Exception {
        bo.setIsFaceVerify(OcrEnum.OcrStatus.FACE_VERIFY.getCode());
        FaceVerifyORCResultVo faceVerifyORCResultVo = idCardVerifyService.faceVerify(bo);
        return RestVo.ok(faceVerifyORCResultVo);
    }

    @PostMapping("/idCardVerify")
    @ApiOperation("身份证2要素校验")
    //@Auth(product = {BaseEnum.ProductEnum.WBM, BaseEnum.ProductEnum.WBM_OFFICE})
    public RestVo<VerifyORCResultVo> idCardVerify(@RequestBody TencentOCRAuthBo bo) throws Exception {
        bo.setIsFaceVerify(OcrEnum.OcrStatus.TWO_ELEMENT.getCode());
        VerifyORCResultVo verifyORCResultVo = idCardVerifyService.idCardVerify(bo);
        return RestVo.ok(verifyORCResultVo);
    }

    @PostMapping("/idCardOcr")
    @ApiOperation("身份证图片ocr")
    //@Auth(product = {BaseEnum.ProductEnum.WBM, BaseEnum.ProductEnum.WBM_OFFICE})
    public RestVo<IdCardVo> idCardOcr(@RequestBody IDOCRAuthBo bo){
        IdCardVo idCardVo = idCardVerifyService.idCardOcr(bo);
        return RestVo.ok(idCardVo);
    }

    @PostMapping("/bizLicenseOcr")
    @ApiOperation("营业执照ocr")
    @Auth(product = {BaseEnum.ProductEnum.WBM, BaseEnum.ProductEnum.WBM_OFFICE, BaseEnum.ProductEnum.BYTE_DANCE})
    public RestVo<BizLicenseVo> bizLicenseOcr(@RequestBody IDOCRAuthBo bo){
        BizLicenseVo bizLicenseVo = idCardVerifyService.bizLicenseOcr(bo);
        return RestVo.ok(bizLicenseVo);
    }

    @PostMapping("/bankCardOcr")
    @ApiOperation("银行卡ocr")
    //@Auth(product = {BaseEnum.ProductEnum.WBM, BaseEnum.ProductEnum.WBM_OFFICE})
    public RestVo<BankCardVo> bankCardOcr(@RequestBody IDOCRAuthBo bo){
        BankCardVo bankCardVo = idCardVerifyService.bankCardOCR(bo);
        return RestVo.ok(bankCardVo);
    }

}
